﻿@using QH.JobBack.Model;
@{
    var add = 0;
    List<Classifyinfo> lists = null;
    if (ViewBag.list != null)
    {
        lists = ViewBag.list;
    }
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
    <!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
    <meta name="renderer" content="webkit">
    <!--国产浏览器高速模式-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="author" content="穷在闹市" />
    <!-- 作者 -->
    <meta name="revised" content="穷在闹市.v3, 2019/05/01" />
    <!-- 定义页面的最新版本 -->
    <meta name="description" content="网站简介" />
    <!-- 网站简介 -->
    <meta name="keywords" content="搜索关键字，以半角英文逗号隔开" />
    <title>穷在闹市出品</title>

    <!-- 公共样式 开始 -->
    <link rel="stylesheet" type="text/css" href="../../css/base.css">
    <link rel="stylesheet" type="text/css" href="../../fonts/iconfont.css">
    <script type="text/javascript" src="../../framework/jquery-1.11.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
    <script type="text/javascript" src="../../layui/layui.js"></script>
    <script src="../../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
    <!-- 公共样式 结束 -->

    <style>

        .layui-form {
            margin-right: 30%;
        }
    </style>

</head>

<body>
    <div class="cBody">
        <form id="addForm" class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">分类名称</label>
                <div class="layui-input-inline shortInput">
                    <input type="text" id="ManagerName" name="title" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
                <i class="iconfont icon-huaban bt"></i>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">父级</label>
                <div class="layui-input-inline shortInput">
                    <select name="class" id="option">
                        <option value="0">当前一级</option>
                        @{ if (ViewBag.list != null)
                            {
                                foreach (var item in lists)
                                {
                                <option value="@item.ClassId">@item.ClassName</option>
                                }
                            }

                        }
                    </select>
                </div>
                <i class="iconfont icon-huaban bt"></i>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-inline shortInput">
                    <input type="text" id="miaoshu" name="title" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
                <i class="iconfont icon-huaban bt"></i>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="yyy" id="stau" lay-skin="switch" lay-filter="switchTest" lay-text="启用|禁用" checked />
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div class="layui-btn" id="btn" lay-submit lay-filter="submitBut">立即提交</div>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

        <!-- 三级省市 插件 -->
        <script src="../../framework/area.js"></script>
        <script src="../../framework/province.js"></script>

    </div>
</body>

</html>
<script>
    $("#btn").click(function () {
        if (@add== 0) {
            var date = {};
            date.ClassName = $("#ManagerName").val();
            date.ParentId = $("#option").val();
            if (date.ParentId == 0) {
                date.LEVEL = 1;
            } else {
                 date.LEVEL = 2;
            }
            date.Remark = $("#miaoshu").val();
            date.Status = $("#stau").prop("checked");
                    $.ajax({
                type:"post",
                url: "/Type/AddManager",
                data: date,
                success: function (json) {
                    if (json.Success) {
                        layer.alert('添加成功！', {
                            title: '提示框',
                            icon: 1,
                        }, function () {
                            location.href = "/Type/TypeManager";
                            });

                    } else {
                        layer.alert('添加失败！', {
                            title: '提示框',
                            icon: 0,
                        });
                        layer.close(MenuSection);
                    }
            }
            });
        } else {

        }
    });
</script>